/**
 * 
 */
package badugi;

/**
 * @author aleks
 *
 */
public class Card implements Comparable<Card> {
/** color which is color of the card
 */
	private int color;
/** value which is calue of the card
 */
	private int value;
/**
 * Constructor
 * @param color int from [1..4]
 * @param value int from [1..13]
 * @throws CardException if color or value isn't in property sections
 */
	Card(int color, int value) throws CardException {
		if (color < 1 || color > 4) throw new CardException(0);
		if (value < 1 || value > 13) throw new CardException(1);
		this.color = color;
		this.value = value;
	}
	/**
	 * @return the color
	 */
	public int getColor() {
		return color;
	}
	/**
	 * @return the value
	 */
	public int getValue() {
		return value;
	}
	public String toString() {
		return  color + "," + value;
	}
	
	@Override
	public int compareTo(Card o) {
		int v = Integer.compare(this.getValue(), o.getValue());
		int c = Integer.compare(this.getColor(), o.getColor());
		if (v != 0) return v;
		else return c;
	}

}
